﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WorkFlowBLL;

namespace QLCF.Forms.Reports
{
    public partial class frmViewlstStockReport : Form
    {
        private DateTime fromDate = DateTime.Now;
        private DateTime toDate = DateTime.Now;
        private int AdminID = -1;
        private string fullName = "Tất cả";
        public frmViewlstStockReport()
        {
            InitializeComponent();
        }
        public frmViewlstStockReport(DateTime m_fromDate,DateTime m_toDate, int m_adminID)
        {
            InitializeComponent();
            fromDate = m_fromDate;
            toDate = m_toDate;
            AdminID = m_adminID;
            CtrAdmin ctra = new CtrAdmin();
            if (AdminID > 0)
                fullName = ctra.GetInfoAdminByAdminID(AdminID).FullName;
        }

        private void frmViewlstStockReport_Load(object sender, EventArgs e)
        {

            string strRPSource = string.Empty;
            CtrBase ctrp = new CtrBase();
            int? totalMoneyAll = 0;
            var items = ctrp.GetAllStockSearch(fromDate, toDate,
                AdminID, ref totalMoneyAll);
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.LocalReport.ReportEmbeddedResource = "QLCF.Reports.rptlstStock.rdlc";

            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmDate", "Từ " + fromDate.ToString("dd/MM/yyyy") + " đến " + toDate.ToString("dd/MM/yyyy")));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmFullName", "Người dùng: " + fullName));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmTotalRecord", items.Count.ToString()));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmTotalMoney", (totalMoneyAll ?? 0) == 0 ? "0 VNĐ" : (totalMoneyAll ?? 0).ToString("0,0") + " VNĐ"));

            reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("lstSearch", items));
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
            reportViewer1.ZoomPercent = 100;
            reportViewer1.RefreshReport();
        }
    }
}
